import Vue from 'vue'
import App from './App'
import router from './router'
import fastClick from 'fastclick'
import store from './store'
import './assets/style/reset.css'
import './assets/style/border.css'
import './assets/style/iconfont.css'

Vue.config.productionTip = false
fastClick.attach(document.body)

// import { Tabbar, TabItem, Swipe, SwipeItem, Button, Cell, Progress, Header, Actionsheet,TabContainer,TabContainerItem } from 'mint-ui';
// Vue.component(Tabbar.name, Tabbar);
// Vue.component(TabItem.name, TabItem);
// Vue.component(Swipe.name, Swipe);
// Vue.component(SwipeItem.name, SwipeItem);
// Vue.component(Button.name, Button);
// Vue.component(Cell.name, Cell);
// Vue.component(Progress.name, Progress);
// Vue.component(Header.name, Header);
// Vue.component(Actionsheet.name, Actionsheet);
// Vue.component(TabContainer.name, TabContainer);
// Vue.component(TabContainerItem.name, TabContainerItem);
import MintUI from 'mint-ui';
import 'mint-ui/lib/style.css';
import './assets/style/modifyMintUIColor.styl';//核心，多了这一行用上边的样式覆盖默认的primary颜色
Vue.use(MintUI);

// 全局组件 开始
import MyUl from './components/common/MyUl';
import MyLi from './components/common/MyLi';
import MyTitle from './components/common/MyTitle';
import MyTitle2 from './components/common/MyTitle2';
import MyTitle3 from './components/common/MyTitle3';
import MyGuide from './components/common/MyGuide';
import MyRoute from './components/common/MyRoute';
import Gallary from './components/gallary/Gallary';
import Calendar from './components/common/Calendar';
import Comment from './components/Comment';
Vue.component(MyUl.name, MyUl);
Vue.component(MyLi.name, MyLi);
Vue.component(MyTitle.name, MyTitle);
Vue.component(MyTitle2.name, MyTitle2);
Vue.component(MyTitle3.name, MyTitle3);
Vue.component(MyGuide.name, MyGuide);
Vue.component(MyRoute.name, MyRoute);
Vue.component(Gallary.name, Gallary);
Vue.component(Calendar.name, Calendar);
Vue.component('Comment', Comment);
// 全局组件 结束

import Axios from 'axios'
//请求时的处理
Axios.interceptors.request.use(config => {
  MintUI.Indicator.open({
    text: '玩命加载中...',
    spinnerType: 'fading-circle'
  });
  return config;
})
//请求成功或失败的处理
Axios.interceptors.response.use(response => {
  console.log(response);
  MintUI.Indicator.close();
  return response;
}, error => {
  MintUI.Indicator.close();
  MintUI.Toast('数据传输失败');
})

//解决页面切换后滚动位置不在顶部的问题
router.afterEach((to,from,next) => {
  window.scrollTo(0,0);
  // 或
  // window.scroll(0, 0);
});

// import VuePreview from 'vue-preview'
// defalut install
// Vue.use(VuePreview) 
// with parameters install
// Vue.use(VuePreview, {
//   mainClass: 'pswp--minimal--dark',
//   barsSize: {top: 0, bottom: 0},
//   captionEl: false,
//   fullscreenEl: false,
//   shareEl: false,
//   bgOpacity: 0.85,
//   tapToClose: true,
//   tapToToggleControls: false
// })

// import { formatDate } from '@/libs/util.js';
// const dateFormat = Vue.filter('dateFormat', date=>{
//   formatDate(date);
// });

//全局服务器图片地址
Vue.prototype.$platIMG = "http://localhost:8080/platIMG/";
// Vue.prototype.$platIMG = "http://59.110.112.232:8080/platIMG/";

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>',
  // filters: {
  //   dateFormat,
  // }
})
